{% extends "base.html" %}

{% block title %}编辑内容 - {{ content.title }}{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">
                    <h4>编辑内容</h4>
                </div>
                <div class="card-body">
                    <form method="POST" action="{{ url_for('edit_content', content_id=content.id) }}">
                        <div class="mb-3">
                            <label for="title" class="form-label">标题</label>
                            <input type="text" class="form-control" id="title" name="title" 
                                   value="{{ content.title }}" required>
                        </div>
                        
                        <div class="mb-3">
                            <label for="description" class="form-label">描述</label>
                            <textarea class="form-control" id="description" name="description" 
                                      rows="3">{{ content.description }}</textarea>
                        </div>
                        
                        <div class="mb-3">
                            <label for="content_type" class="form-label">内容类型</label>
                            <select class="form-select" id="content_type" name="content_type" required>
                                <option value="article" {% if content.content_type == 'article' %}selected{% endif %}>文章</option>
                                <option value="video" {% if content.content_type == 'video' %}selected{% endif %}>视频</option>
                                <option value="image" {% if content.content_type == 'image' %}selected{% endif %}>图片</option>
                                <option value="audio" {% if content.content_type == 'audio' %}selected{% endif %}>音频</option>
                            </select>
                        </div>
                        
                        <div class="mb-3">
                            <label for="status" class="form-label">状态</label>
                            <select class="form-select" id="status" name="status">
                                <option value="draft" {% if content.status == 'draft' %}selected{% endif %}>草稿</option>
                                <option value="published" {% if content.status == 'published' %}selected{% endif %}>已发布</option>
                                <option value="archived" {% if content.status == 'archived' %}selected{% endif %}>已归档</option>
                            </select>
                        </div>
                        
                        <div class="d-grid gap-2 d-md-flex justify-content-md-between">
                            <div>
                                <button type="submit" class="btn btn-primary">保存更改</button>
                                <a href="{{ url_for('manage_content') }}" class="btn btn-outline-secondary">取消</a>
                            </div>
                            <button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#deleteModal">
                                删除内容
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 删除确认模态框 -->
<div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="deleteModalLabel">确认删除</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                确定要删除"{{ content.title }}"吗？此操作无法撤销。
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                <form action="{{ url_for('edit_content', content_id=content.id) }}" method="POST">
                    <input type="hidden" name="_method" value="DELETE">
                    <button type="submit" class="btn btn-danger">确认删除</button>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}
